package com.hebeu.device.controller;

import com.hebeu.device.pojo.DUserRole;
import com.hebeu.device.service.RoleService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/*
    角色（权限）管理控制器
 */
@RestController
@RequestMapping("/role")
public class RoleController {

    @Resource
    RoleService roleService;

    //查询
    @GetMapping("/getRole")
    public List<DUserRole> getRole(DUserRole dUserRole){
        return roleService.getRole(dUserRole);
    }


    //增
    @PostMapping("/addRole")
    public int addRole(DUserRole dUserRole){
        return roleService.addRole(dUserRole);
    }

    //改
    @PostMapping("/updateRole")
    public int updateRole(DUserRole dUserRole){
        return roleService.updateRole(dUserRole);
    }
    //删
    @PostMapping("delRole")
    public int delRole(DUserRole dUserRole){
        System.out.println("进入角色失效方法");
        return roleService.delRole(dUserRole);
    }
    //全查
    @GetMapping("/getAll")
    public List<DUserRole> getAllRole(DUserRole dUserRole){
        return roleService.getAllRole(dUserRole);
    }
    //id查
    @GetMapping("/getOne")
    public DUserRole getRoleById(int rId){
        return roleService.getRoleById(rId);
    }
}
